<?php

use yii\helpers\Html;
use yii\helpers\Url;
use yii\grid\GridView;

/**
 * @var yii\web\View $this
 * @var yii\data\ActiveDataProvider $dataProvider
 * @var yiike\finance\models\TokerWithdrawSearch $searchModel
 */

$this->title = Yii::t('models', '推手提现');
$this->params['breadcrumbs'][] = $this->title;

if (isset($actionColumnTemplates)) {
    $actionColumnTemplate = implode(' ', $actionColumnTemplates);
    $actionColumnTemplateString = $actionColumnTemplate;
} else {
    Yii::$app->view->params['pageButtons'] = Html::a('<span class="glyphicon glyphicon-plus"></span> ' . 'New', ['create'], ['class' => 'btn btn-success']);
    $actionColumnTemplateString = "{update}";
}
$actionColumnTemplateString = '<div class="action-buttons">'.$actionColumnTemplateString.'</div>';
?>
<?php
echo $this->render('_search', ['model' =>$searchModel]);
?>
<div class="box box-info giiant-crud toker-withdraw-index">
    <div class="box-header with-border">
        <div class="box-title">
            <?= Yii::t('models', '推手提现') ?>
        </div>
    </div>
    <div class="box-body">


        <?php \yii\widgets\Pjax::begin(['id'=>'pjax-main', 'enableReplaceState'=> false, 'linkSelector'=>'#pjax-main ul.pagination a, th a', 'clientOptions' => ['pjax:success'=>'function(){alert("yo")}']]) ?>

        <div class="table-responsive">
            <?= GridView::widget([
                'dataProvider' => $dataProvider,
                'pager' => [
                    'class' => yii\widgets\LinkPager::className(),
                    'firstPageLabel' => 'First',
                    'lastPageLabel' => 'Last',
                ],
                'tableOptions' => ['class' => 'table table-striped table-bordered table-hover'],
                'headerRowOptions' => ['class'=>'x'],
                'columns' => [
                    [
                        'class' => 'yii\grid\ActionColumn',
                        'template' => $actionColumnTemplateString,
                        'buttons' => [
                            'view' => function ($url, $model, $key) {
                                $options = [
                                    'title' => Yii::t('cruds', 'View'),
                                    'aria-label' => Yii::t('cruds', 'View'),
                                    'data-pjax' => '0',
                                    'class' => 'btn btn-default btn-xs',
                                ];
                                return Html::a('<span class="fa fa-file-o"></span>', $url, $options);
                            },
                            'update' => function ($url, $model, $key) {
                                $options = [
                                    'title' => Yii::t('cruds', 'View'),
                                    'aria-label' => Yii::t('cruds', 'View'),
                                    'data-pjax' => '0',
                                    'class' => 'btn btn-danger btn-sm',
                                ];
                                return Html::a('<span class="fa fa-pencil-square-o"></span> 处理', $url, $options);
                            }
                        ],
                        'urlCreator' => function($action, $model, $key, $index) {
                            // using the column name as key, not mapping to 'id' like the standard generator
                            $params = is_array($key) ? $key : [$model->primaryKey()[0] => (string) $key];
                            $params[0] = \Yii::$app->controller->id ? \Yii::$app->controller->id . '/' . $action : $action;
                            return Url::toRoute($params);
                        },
                        'contentOptions' => ['nowrap'=>'nowrap']
                    ],
                    [
                        'attribute' => 'status',
                        'content' => function ($model) {
                            $status = $model->status_option[$model->status];
                            $class = 'label-default';
                            switch ($model->status) {
                                case 0:
                                    $class = 'label-info';
                                    break;
                                case 1:
                                    $class = 'label-success';
                                    break;
                                case 2:
                                    $class = 'label-danger';
                                    break;
                                case 3:
                                    $class = 'label-warning';
                                    break;
                            }

                            return Html::a($status, null, ['class' =>'label '.$class]);
                        }
                    ],
                    [
                        'attribute' => 'is_pay',
                        'content' => function ($model) {
                            $status = $model->pay_option[$model->is_pay];
                            $class = 'label-default';
                            switch ($model->is_pay) {
                                case 0:
                                    $class = $model->status == 1 ? 'label-warning' : 'label-default';
                                    break;
                                case 1:
                                    $class = 'label-success';
                                    break;
                            }

                            return Html::a($status, null, ['class' =>'label '.$class]);
                        }
                    ],
                    'toker.name',
                    'money',
                    [
                        'attribute' => 'type',
                        'value' => function ($model) {
                            return $model->type_option[$model->type];
                        }
                    ],
                    [
                        'header' => '支付宝/银行卡',
                        'content' => function ($model) {
                            return $model->bank . ' '. $model->payee. ' '. $model->bank_account;
                            switch ($model->type) {
                                case 1:
                                    return $model->wx_openid;
                                    break;
                                case 2:
                                    return $model->alipay;
                                    break;
                                case 3:
                                    return $model->bank_account . "\n".$model->bank;
                                    break;
                            }
                            return '';
                        }
                    ],
                    'pay_sn',
                    'created_at:datetime',
                    'check_at:datetime',
                    'pay_at:datetime',
                ],
            ]); ?>
        </div>
        <?php \yii\widgets\Pjax::end() ?>
    </div>
</div>




